<!DOCTYPE html>
<html lang="en" xmlns:v-for="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>演示filter作用</title>
    <script src="../../js/vue/vue.js"></script>
</head>
<body>
<div id="app">
    <span v-for="u in user">{{u.sex|sexFilter}}</span>
</div>
<script>
    // 全局Filter
    Vue.filter('sexFilter', function (value) {
        return value == 1 ? '男' : '女';
    });
    var app = new Vue({
        el: '#app',
        data: {
            user: [
                {name: "张三", sex: 1}
            ]
        }
        // filter主要用于数据格式化和加工
        /*filters: {
            sexFilter: function (value) {
                return value === 1 ? '男' : '女';
            }
        }*/
    })
</script>
</body>
</html>